package com.jwthhealth_pub.old.report.view.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.old.common.ImageLoader;
import com.jwthhealth_pub.old.report.view.SportDetailExplActivity;

import java.util.List;

/**
 * Created by liuzhen on 2017/10/26.
 */

public class DetailPicAdapter extends RecyclerView.Adapter {
    private final SportDetailExplActivity mActivity;
    private final List<String> mData;

    public DetailPicAdapter(SportDetailExplActivity sportDetailExplActivity, List<String> thumb_list) {
        this.mActivity = sportDetailExplActivity;
        this.mData = thumb_list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(View.inflate(mActivity, R.layout.item_sport_detail_pic, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        String s = mData.get(position);
        if (s == null) return;

        ViewHolder vh = (ViewHolder) holder;
        ImageLoader.picasso(s, vh.img);
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    private class ViewHolder extends RecyclerView.ViewHolder {

        ImageView img;

        public ViewHolder(View itemView) {
            super(itemView);

            img = itemView.findViewById(R.id.img);
        }
    }
}
